import { ScrollView, View, Text } from '@tarojs/components';
import React, { Component } from 'react';
import Taro, { getCurrentInstance } from '@tarojs/taro';
import { connect } from 'react-redux';
import './index.less';
import * as T from './types';
import actions from './actions';
import { store2Props } from './selectors';
import Top from './components/top';
import Left from './components/left';
import Bottom from './components/bottom';

actions().actions.loadReducer();
// @ts-ignore
@connect<Partial<T.IProps>, any>(store2Props, actions)
export default class Index extends Component<Partial<T.IProps>, any> {
  constructor(props) {
    super(props);
    this.state = {
      type: ''
    };
  }

  componentDidMount() {
    let type = getCurrentInstance().router.params.type;
    this.setState({ type: type })
  }

  componentDidShow() { }

  componentWillUnmount() { }

  render() {
    let { type } = this.state;
    return (
      <View>
        {
          type == 0 && <Top />
        }
        {
          type == 1 && <Left />
        }
        {
          type == 2 && <Bottom />
        }
      </View>
    );
  }
}
